function durationFormat(duration) {
    if (duration === undefined || duration === null) {
        return ""
    }
    let totalSeconds = Math.floor(duration / 1000);
    // 计算天数
    const days = Math.floor(totalSeconds / 86400);
    totalSeconds %= 86400;

    // 计算小时数
    const hours = Math.floor(totalSeconds / 3600);
    totalSeconds %= 3600;

    // 计算分钟数
    const minutes = Math.floor(totalSeconds / 60);
    totalSeconds %= 60;

    // 剩余的秒数即为总秒数余下的部分
    const seconds = totalSeconds;

    // 格式化输出，仅在天数大于等于1时显示天数
    let formattedTime = '';
    if (days >= 1) {
        formattedTime += `${days}天`;
    }
    if (hours > 0) {
        formattedTime += `${hours}小时`
    }
    if (minutes > 0) {
        formattedTime += `${minutes}分`
    }
    formattedTime += `${seconds}秒`;
    return formattedTime;
}

const startDurationTools = {
    durationFormat
}
export default startDurationTools